<?php

include_once 'admin_access.php';

if(isset($_POST['sm1'])){	
	$user_name = trim($_POST['user_name']);
	$pwd = trim($_POST['pwd']);
	
	if($user_name == '' || $pwd == ''){
		echo "<script>alert('提示：用户名和密码不能为空！');</script>";
	} elseif (DB::fetch_first("SELECT * FROM `om_admin_user` WHERE name = '$user_name'")){
		echo "<script>alert('提示：该用户名已经存在了！');</script>";
	} else {
		if(DB::insert('admin_user', array('name' => $user_name, 'pwd' => md5($pwd), 'register_time' => time()))){
			echo "<script>alert('提示：添加成功！');</script>";
		}
	}
}

?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="css/base.css">
<link rel="stylesheet" type="text/css" href="css/indexbody.css">

</head>
<body leftmargin="8" topmargin="8" bgcolor="#FFFFFF">
<div style="min-width:780px">
<table align="center" border="0" cellpadding="0" cellspacing="0" width="98%">
  <tbody><tr>
    <td>
     <div id="" style="float:right;padding-right:8px;">
     </div>
   </td>
  </tr>
  <tr>
    <td style="padding: 0px;" background="css/sp_bg.gif" height="1"></td>
  </tr>
</tbody></table>
<div id="__testEvn"></div>
<div id="mainmsg">
  <div class="column" id="column1"><!--左侧开始-->    
        <dl class="dbox" id="item1">
            <dt class="lside"><span class="l"> 添加用户</span></dt>
            <dd>
				<form method="post">
				<table>
					<tr>
						<td>用户名：<input type="text" name="user_name"/></td>						
					</tr>
					<tr>
						<td>密&nbsp;&nbsp;码：<input type="password" name="pwd"/></td>						
					</tr>
					<tr>
						<td><button type="submit" name="sm1">添加</button></td>						
					</tr>
				</table>
				</form>
            </dd>
        </dl>
    </div>
</div>
<br style="clear:both">
<div class="footer" align="center">
Copyright © 2004-2012
</div>
</div>
</body></html>